<?php //include 'models/Article';               ?>
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of GAlert
 *
 * @author bach.le
 */
class SearchWidget extends CWidget {

    protected $isAjaxRequest;
    public $target = '#btnFilterCommon';
    //put your code here
    public function run() {
        $urlsearch = Yii::app()->baseUrl."/search";
        $assets = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias(
                        'ext.Search') . '/assets');

        // Register extension assets
        $cs = Yii::app()->getClientScript();
        Yii::app()->clientScript->registerCoreScript('jquery');
        // Register extension assets
        $cs->registerCssFile($assets . '/css/Search.css');
        echo '<div>';
        echo '<div id ="txtsearch">';
        echo CHtml::textField("", "", array('autocomplete' => 'off', 'style' => 'width:150px',
            'placeholder' => 'Search...',
            'class' => 'keyword',
            'id' => 'keyword'
        ));
        echo '</div>';
        echo "<div id=\"btnFilterCommon\" class=\"icon_search\">&nbsp;</div>";
        echo '</div>';
        
         $cs->registerScript( 'searchwidget', "
            jQuery( '{$this->target}' ).live( 'click', function(){
            window.location.href=\"".$urlsearch."?keyword=\"+$(\"#keyword\").val();
        });",
      CClientScript::POS_END );
    }
}

?>
